/**
 *
 */
package net.haroeris.wh40kcampaign.dao;

import java.util.HashMap;
import java.util.Map;

/**
 * @author user
 *
 */
public enum Authorities {
    Users( "ROLE_USER", "Normale Benutzer" ),
    Adminsitrators( "ROLE_ADMIN", "Administratoren der Anwendung." );

    private String authority;
    private String description;

    private static Map<String,Authorities> authorityMapping;

    static {
        authorityMapping= new HashMap<String, Authorities>(Authorities.values().length);

        for( Authorities auth : Authorities.values() ){
            authorityMapping.put(auth.getAuthority(), auth);
        }
    }

    private Authorities( String authorityString, String description){
        setAuthority(authorityString);
        setDescription(description);
    }

    public static Authorities getByAuthorities(String authString){
        if( authString!=null ){
            return authorityMapping.get(authString);
        }
        return null;
    }

    /**
     * @return the authority
     */
    public String getAuthority() {
        return authority;
    }

    /**
     * @param authority the authority to set
     */
    private void setAuthority(String authority) {
        this.authority = authority;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    private void setDescription(String description) {
        this.description = description;
    }
}